﻿$(document).ready(function () {
    $('#addcomments').bind('blur', function () {
        var line = "-------------------------------------------------------";
        var myDate = new Date();
        var myFormattedDate = myDate.f("dd/MM/yyyy HH:mm:ss");
        $("#TRU_DetailsView1_Comments").prepend($("#Header_lblUser").text() + ' -  ' + myFormattedDate + ' - ' + $('#addcomments').val() + '\n' + line + '\n');
    });

    

    if (($("#Header_lblUser").text() == 'Liang Zhao') || ($("#Header_lblUser").text() == 'Omar Sabbagh') || ($("#Header_lblUser").text() == 'Andrew Caragher')) {
        $("#TRU_DetailsView1_OperatorSSE").show();
        $("#TRU_DetailsView1_selOperatorSSE").show();
    }
    else {
        $("#TRU_DetailsView1_OperatorSSE").hide();
        $("#TRU_DetailsView1_selOperatorSSE").hide();
    }

    if (($("#Header_lblUser").text() == 'Grant Mayhew')) {
        $("#TRU_DetailsView1_OperatorSSE").val('Grant Mayhew');
        $("#TRU_DetailsView1_PromotionCode").val('Grant Mayhew');
        $("#TRU_DetailsView1_LeadSource").val('BPO');
        //$("#TRU_DetailsView1_OperatorSSE").show();
        //$("#TRU_DetailsView1_selOperatorSSE").show();
    }
    if ($("#Header_lblUser").text() == 'Ian Wilson') {
        $("#TRU_DetailsView1_OperatorSSE").val('Ian Wilson');
        $("#TRU_DetailsView1_PromotionCode").val('Ian Wilson');
        $("#TRU_DetailsView1_LeadSource").val('BPO');
        //$("#TRU_DetailsView1_OperatorSSE").show();
        //$("#TRU_DetailsView1_selOperatorSSE").show();
    }
    if ($("#Header_lblUser").text() == 'Brian Barlin') {
        $("#TRU_DetailsView1_OperatorSSE").val('Brian Barlin');
        $("#TRU_DetailsView1_PromotionCode").val('Brian Barlin');
        $("#TRU_DetailsView1_LeadSource").val('BPO');
        //$("#TRU_DetailsView1_OperatorSSE").show();
        //$("#TRU_DetailsView1_selOperatorSSE").show();
    }
    if ($("#Header_lblUser").text() == 'James Rose') {
        $("#TRU_DetailsView1_OperatorSSE").val('James Rose');
        $("#TRU_DetailsView1_PromotionCode").val('James Rose');
        $("#TRU_DetailsView1_LeadSource").val('BPO');
        //$("#TRU_DetailsView1_OperatorSSE").show();
        //$("#TRU_DetailsView1_selOperatorSSE").show();
    }
    if ($("#Header_lblUser").text() == 'Ben Shuttleworth') {
        $("#TRU_DetailsView1_OperatorSSE").val('Ben Shuttleworth');
        $("#TRU_DetailsView1_PromotionCode").val('Ben Shuttleworth');
        $("#TRU_DetailsView1_LeadSource").val('BPO');
        //$("#TRU_DetailsView1_OperatorSSE").show();
        //$("#TRU_DetailsView1_selOperatorSSE").show();
    }


    if ($('#DetailsView0_lbluserID').text() == '') {
        $("#TRU_DetailsView1_UpdateButton").hide();
        $("#TRU_DetailsView1_DeleteButton").hide();

        if ($('#TRU_DetailsView1_AccountStatus').val() == '') {
            $("#TRU_DetailsView1_AccountStatus").val('0');
            $("#TRU_DetailsView1_StatusName").val('Status Not Set');
        }

         $("#TRU_DetailsView1_OperatorSSE").val($("#Header_lblUser").text());
    }

    else {
        $("#TRU_DetailsView1_InsertButton").hide();
        $("#TRU_DetailsView1_CancelButton").hide();
    }

    if ($('#TRU_DetailsView1_PromotionCode').val() == 'GOLFNSW') {
        $("#TRU_DetailsView1_GolfClub").show();
    }
    else {
        $("#TRU_DetailsView1_GolfClub").hide();
    }

	$("#TRU_DetailsView1_TypeOrg").val($('#DetailsView0_TypeOrg').val());

    if ($('#TRU_DetailsView1_TypeOrg').val() == 'RESI') {
        $("#TRU_DetailsView1_RESI_SME").val('RESI');
        $('#TRU_DetailsView1_SecondAccountHolderTitle').hide();
        $('#TRU_DetailsView1_selSecondAccountHolderTitle').hide();
        $('#TRU_DetailsView1_SecondAccountHolderFirstName').hide();
        $('#TRU_DetailsView1_SecondAccountHolderSurname').hide();
        $('#TRU_DetailsView1_SecondAccountHolderDOB').hide();
        $('#TRU_DetailsView1_selConcessionCardType').hide();
        $('#TRU_DetailsView1_ConcessionCardType').hide();
        $('#TRU_DetailsView1_ConcessionCardEntitlement').hide();
        $('#TRU_DetailsView1_ConcessionCardNo').hide();
        $('#TRU_DetailsView1_ConcessionCardExp').hide();
        $('#TRU_DetailsView1_NameOnConcessionCard').hide();
        $('#TRU_DetailsView1_selSourceCodeSME').hide();
        $('#TRU_DetailsView1_selProductTypeSME').hide();
    }
    if (($('#TRU_DetailsView1_TypeOrg').val() == 'SME') || ($('#TRU_DetailsView1_TypeOrg').val() == 'C&I')) {
        $("#TRU_DetailsView1_RESI_SME").val('SME');
        $('#TRU_DetailsView1_selSecondAccountHolder').hide();
        $('#TRU_DetailsView1_SecondAccountHolderTitle').hide();
        $('#TRU_DetailsView1_selSecondAccountHolderTitle').hide();
        $('#TRU_DetailsView1_SecondAccountHolderFirstName').hide();
        $('#TRU_DetailsView1_SecondAccountHolderSurname').hide();
        $('#TRU_DetailsView1_SecondAccountHolderDOB').hide();
        $('#TRU_DetailsView1_selConcessionCard').hide();
        $('#TRU_DetailsView1_selConcessionCardType').hide();
        $('#TRU_DetailsView1_ConcessionCardType').hide();
        $('#TRU_DetailsView1_ConcessionCardEntitlement').hide();
        $('#TRU_DetailsView1_ConcessionCardNo').hide();
        $('#TRU_DetailsView1_ConcessionCardExp').hide();
        $('#TRU_DetailsView1_NameOnConcessionCard').hide();
        $('#TRU_DetailsView1_selSourceCodeRESI').hide();
        $('#TRU_DetailsView1_selProductTypeRESI').hide();

    }

    if (($('#TRU_DetailsView1_ElectricityConversion').val() == 'NO') || ($('#TRU_DetailsView1_ElectricityConversion').val() == '')) {
        $("#TRU_DetailsView1_ElectricityConversion").val('NO');
        $("#TRU_DetailsView1_Elec").val('NO');
        $("#TRU_DetailsView1_ElecMonthQuarter").hide();
        $("#TRU_DetailsView1_selElecMonthQuarter").hide();
        $("#TRU_DetailsView1_ElecMonthQuarterSpend").hide();
        $("#TRU_DetailsView1_selElecSpend").hide();
        $("#TRU_DetailsView1_ElecTotalAnnualSpend").hide();
        $("#TRU_DetailsView1_NMI").hide();
    }

    if (($('#TRU_DetailsView1_GasConversion').val() == 'NO') || ($('#TRU_DetailsView1_GasConversion').val() == '')) {
        $("#TRU_DetailsView1_GasConversion").val('NO');
        $("#TRU_DetailsView1_Gas").val('NO');
        $("#TRU_DetailsView1_GasMonthQuarter").hide();
        $("#TRU_DetailsView1_selGasMonthQuarter").hide();
        $("#TRU_DetailsView1_GasMonthQuarterSpend").hide();
        $("#TRU_DetailsView1_selGasSpend").hide();
        $("#TRU_DetailsView1_GasTotalAnnualSpend").hide();
        $("#TRU_DetailsView1_MIRN").hide();
    }

    if ($('#TRU_DetailsView1_MoverSwicher').val() == 'Swicher')
        $('#TRU_DetailsView1_MoveInDate').hide();

    $("#TRU_DetailsView1_NewProvider").val($('#DetailsView0_NewProvider').val());
    $("#TRU_DetailsView1_TypeOrg").val($('#DetailsView0_TypeOrg').val());
    $("#TRU_DetailsView1_StatusName").val($('#DetailsView0_StatusName').val());
});

function CurrentProviderChanged() {
    $("#TRU_DetailsView1_CurrentProvider").val($('#TRU_DetailsView1_selCurrentProvider').val());
}

function SecondAccountHolderChanged() {
    if ($("#TRU_DetailsView1_selSecondAccountHolder").val() == 'NO') {
        $('#TRU_DetailsView1_SecondAccountHolderTitle').hide();
        $('#TRU_DetailsView1_selSecondAccountHolderTitle').hide();
        $('#TRU_DetailsView1_SecondAccountHolderFirstName').hide();
        $('#TRU_DetailsView1_SecondAccountHolderSurname').hide();
        $('#TRU_DetailsView1_SecondAccountHolderDOB').hide();
    }
    if ($("#TRU_DetailsView1_selSecondAccountHolder").val() == 'YES') {
        $('#TRU_DetailsView1_SecondAccountHolderTitle').show();
        $('#TRU_DetailsView1_selSecondAccountHolderTitle').show();
        $('#TRU_DetailsView1_SecondAccountHolderFirstName').show();
        $('#TRU_DetailsView1_SecondAccountHolderSurname').show();
        $('#TRU_DetailsView1_SecondAccountHolderDOB').show();
    }
}

function ConcessionCardChanged() {
    if ($("#TRU_DetailsView1_selConcessionCard").val() == 'NO') {
        $('#TRU_DetailsView1_selConcessionCardType').hide();
        $('#TRU_DetailsView1_ConcessionCardType').hide();
        $('#TRU_DetailsView1_ConcessionCardEntitlement').hide();
        $('#TRU_DetailsView1_ConcessionCardNo').hide();
        $('#TRU_DetailsView1_ConcessionCardExp').hide();
        $('#TRU_DetailsView1_NameOnConcessionCard').hide();
    }
    if ($("#TRU_DetailsView1_selConcessionCard").val() == 'YES') {
        $('#TRU_DetailsView1_selConcessionCardType').show();
        $('#TRU_DetailsView1_ConcessionCardType').show();
        $('#TRU_DetailsView1_ConcessionCardEntitlement').show();
        $('#TRU_DetailsView1_ConcessionCardNo').show();
        $('#TRU_DetailsView1_ConcessionCardExp').show();
        $('#TRU_DetailsView1_NameOnConcessionCard').show();
    }
}

function CopyNameClick() {
    $("#TRU_DetailsView1_FirstAccountHolderFirstName").val($('#DetailsView0_FirstName').val());
    $("#TRU_DetailsView1_FirstAccountHolderSurname").val($('#DetailsView0_LastName').val());
}
function CopyAddressClick() {
    $("#TRU_DetailsView1_SupplyAddress").val($('#DetailsView0_Street').val());
    $("#TRU_DetailsView1_SupplyAddressSuburb").val($('#DetailsView0_Suburb').val());
    $("#TRU_DetailsView1_SupplyAddressState").val($('#DetailsView0_StateName').val());
    $("#TRU_DetailsView1_SupplyAddressPostcode").val($('#DetailsView0_Postcode').val());
}
function copybottonclick() {
    $("#TRU_DetailsView1_AccountHolderCompanyName").val($('#TRU_DetailsView1_CompanyName').val());
    $("#TRU_DetailsView1_FirstAccountHolderFirstName").val($('#TRU_DetailsView1_FirstName').val());
    $("#TRU_DetailsView1_FirstAccountHolderSurname").val($('#TRU_DetailsView1_LastName').val());
    $("#TRU_DetailsView1_ContactTel").val($('#TRU_DetailsView1_Phone').val());
    $("#TRU_DetailsView1_SecondTel").val($('#TRU_DetailsView1_Mobile').val());
    $("#TRU_DetailsView1_SupplyAddress").val($('#TRU_DetailsView1_Street').val());
    $("#TRU_DetailsView1_SupplyAddressSuburb").val($('#TRU_DetailsView1_Suburb').val());
    $("#TRU_DetailsView1_SupplyAddressState").val($('#TRU_DetailsView1_StateName').val());
    $("#TRU_DetailsView1_SupplyAddressPostcode").val($('#TRU_DetailsView1_Postcode').val());
}

function StateNameChanged() {
    $("#TRU_DetailsView1_StateName").val($('#TRU_DetailsView1_selStateName').val());
}

function PreferredTimeChanged() {
    $("#TRU_DetailsView1_PreferredTime").val($('#TRU_DetailsView1_selPreferredTime').val());
}

function PromotionCodeChanged() {
    $("#TRU_DetailsView1_PromotionCode").val($('#TRU_DetailsView1_selPromotionCode').val());
    $("#TRU_DetailsView1_LeadSource").val($('#TRU_DetailsView1_selPromotionCode').val());

    if ($('#TRU_DetailsView1_PromotionCode').val() == 'CRICKET NSW CLUBS') {
        $("#TRU_DetailsView1_LeadSource").val('CRICKET NSW');
    }
    if ($('#TRU_DetailsView1_PromotionCode').val() == 'CRICKET NSW') {
        $("#TRU_DetailsView1_LeadSource").val('CRICKET NSW');
    }

    if ($('#TRU_DetailsView1_PromotionCode').val() == 'SEA EAGLES') {
        $("#TRU_DetailsView1_LeadSource").val('SEA EAGLES');
    }
    if ($('#TRU_DetailsView1_PromotionCode').val() == 'SEA EAGLES B2B') {
        $("#TRU_DetailsView1_LeadSource").val('SEA EAGLES');
    }

    if ($('#TRU_DetailsView1_PromotionCode').val() == 'GOLFNSW') {
        $("#TRU_DetailsView1_GolfClub").show();
    }
}

function CustomerTypeChanged() {
    $("#TRU_DetailsView1_CustomerType").val($('#TRU_DetailsView1_selCustomerType').val());
}

function LeadSourceChanged() {
    $("#TRU_DetailsView1_LeadSource").val($('#TRU_DetailsView1_selLeadSource').val());
}

function AdminFeeChanged() {
    $("#TRU_DetailsView1_AdminFee").val($('#TRU_DetailsView1_selAdminFee').val());
}
function AccountStatusChanged() {
    $("#TRU_DetailsView1_AccountStatus").val($('#TRU_DetailsView1_selAccountStatus').val());
    $("#TRU_DetailsView1_StatusName").val($('#TRU_DetailsView1_selAccountStatus').find(":selected").text());
    var myDate = new Date();
    var myFormattedDate1 = myDate.f("yyyy-MM-dd");
    var myFormattedDate2 = myDate.f("dd/MM/yyyy HH:mm:ss");
    var mytext = $('#TRU_DetailsView1_selAccountStatus').find(":selected").text()//$('#TRU_DetailsView1_selAccountStatus').text();
    $("#TRU_DetailsView1_AccountStatusHistory").prepend($("#Header_lblUser").text() + ' -  ' + myFormattedDate2 + ' - ' + mytext + '\n');
    if ($('#TRU_DetailsView1_selAccountStatus').val() == '9') {
        $("#TRU_DetailsView1_DateConverted").val(myFormattedDate1);
        if ($("#TRU_DetailsView1_OperatorSSE").val() == '') {
            $("#TRU_DetailsView1_OperatorSSE").show();
            $("#TRU_DetailsView1_selOperatorSSE").show();
            $("#TRU_DetailsView1_OperatorSSE").val($("#Header_lblUser").text());
        }
    }
}

function ProductNameChanged() {

    $("#TRU_DetailsView1_ProductNameID").val($('#TRU_DetailsView1_selProductName').val());
}

function TotalSitesChanged() {

    $("#TRU_DetailsView1_TotalSites").val($('#TRU_DetailsView1_selTotalSites').val());
}

function ElecMonthQuarterChanged() {
    $("#TRU_DetailsView1_ElecMonthQuarter").val($('#TRU_DetailsView1_selElecMonthQuarter').val());
}

function GasMonthQuarterChanged() {
    $("#TRU_DetailsView1_GasMonthQuarter").val($('#TRU_DetailsView1_selGasMonthQuarter').val());
}

function ElecSpendChanged() {
    $("#TRU_DetailsView1_ElecMonthQuarterSpend").val($('#TRU_DetailsView1_selElecSpend').val());
    var ElecMultiply = 0;
    if ($('#TRU_DetailsView1_ElecMonthQuarter').val() == 'Quarter') {
        ElecMultiply = 4;
    }
    if ($('#TRU_DetailsView1_ElecMonthQuarter').val() == 'Month') {
        ElecMultiply = 12;
    }
    var elecSpendvalue = $('#TRU_DetailsView1_ElecMonthQuarterSpend').val() * ElecMultiply;
    var gasSpendvalue = $('#TRU_DetailsView1_GasTotalAnnualSpend').val() * 1;
    var total = elecSpendvalue + gasSpendvalue;
    $("#TRU_DetailsView1_ElecTotalAnnualSpend").val(elecSpendvalue);
    $("#TRU_DetailsView1_TotalAnnualSpend").val(total);
}

function GasSpendChanged() {
    $("#TRU_DetailsView1_GasMonthQuarterSpend").val($('#TRU_DetailsView1_selGasSpend').val());
    var GasMultiply = 0;
    if ($('#TRU_DetailsView1_GasMonthQuarter').val() == 'Quarter') {
        GasMultiply = 4;
    }
    if ($('#TRU_DetailsView1_GasMonthQuarter').val() == 'Month') {
        GasMultiply = 12;
    }
    var elecSpendvalue = $('#TRU_DetailsView1_ElecTotalAnnualSpend').val() * 1;
    var gasSpendvalue = $('#TRU_DetailsView1_GasMonthQuarterSpend').val() * GasMultiply;
    var total = elecSpendvalue + gasSpendvalue;
    $("#TRU_DetailsView1_GasTotalAnnualSpend").val(gasSpendvalue);
    $("#TRU_DetailsView1_TotalAnnualSpend").val(total);
}

function OperatorSSEChanged() {

    $("#TRU_DetailsView1_OperatorSSE").val($('#TRU_DetailsView1_selOperatorSSE').val());

    if ($('#TRU_DetailsView1_OperatorSSE').val() == 'Edia Fisher') {
        $("#TRU_DetailsView1_VendorID").val('STSM0001001-STSM001500');
    }
    else if ($('#TRU_DetailsView1_OperatorSSE').val() == 'Omar Sabbagh') {
        $("#TRU_DetailsView1_VendorID").val('STSM0001501-STSM0002000');
    }
    else if ($('#TRU_DetailsView1_OperatorSSE').val() == 'Kelvin Wiggins') {
        $("#TRU_DetailsView1_VendorID").val('STSM0004001-STSM0004500');
    }
    else {
        ;
    }
}

function VendorIDChanged() {

    $("#TRU_DetailsView1_VendorID").val($('#TRU_DetailsView1_selVendorID').val());

    if ($('#TRU_DetailsView1_VendorID').val() == 'STSM0001001-STSM001500') {
        $("#TRU_DetailsView1_OperatorSSE").val('Edia Fisher');
    }
    else if ($('#TRU_DetailsView1_VendorID').val() == 'STSM0001501-STSM0002000') {
        $("#TRU_DetailsView1_OperatorSSE").val('Omar Sabbagh');
    }
    else if ($('#TRU_DetailsView1_VendorID').val() == 'STSM0004001-STSM0004500') {
        $("#TRU_DetailsView1_OperatorSSE").val('Kelvin Wiggins');
    }
    else {
        ;
    }
}

function TypeOrgChanged() {

    $("#TRU_DetailsView1_TypeOrg").val($('#TRU_DetailsView1_selTypeOrg').val());
    if ($('#TRU_DetailsView1_selTypeOrg').val() == 'RESI') {
        $("#TRU_DetailsView1_RESI_SME").val('RESI');
        $('#TRU_DetailsView1_CopyName').show();
        $('#TRU_DetailsView1_FirstAccountHolderTitle').show();
        $('#TRU_DetailsView1_selFirstAccountHolderTitle').show();
        $('#TRU_DetailsView1_FirstAccountHolderFirstName').show();
        $('#TRU_DetailsView1_FirstAccountHolderSurname').show();
        $('#TRU_DetailsView1_FirstAccountHolderDOB').show();
        $('#TRU_DetailsView1_selSecondAccountHolder').show();
        $('#TRU_DetailsView1_SecondAccountHolderTitle').hide();
        $('#TRU_DetailsView1_selSecondAccountHolderTitle').hide();
        $('#TRU_DetailsView1_SecondAccountHolderFirstName').hide();
        $('#TRU_DetailsView1_SecondAccountHolderSurname').hide();
        $('#TRU_DetailsView1_SecondAccountHolderDOB').hide();
        $('#TRU_DetailsView1_selConcessionCard').show();
        $('#TRU_DetailsView1_selConcessionCardType').hide();
        $('#TRU_DetailsView1_ConcessionCardType').hide();
        $('#TRU_DetailsView1_ConcessionCardEntitlement').hide();
        $('#TRU_DetailsView1_ConcessionCardNo').hide();
        $('#TRU_DetailsView1_ConcessionCardExp').hide();
        $('#TRU_DetailsView1_NameOnConcessionCard').hide();
        $('#TRU_DetailsView1_selSourceCodeSME').hide();
        $('#TRU_DetailsView1_selProductTypeSME').hide();
        $('#TRU_DetailsView1_selSourceCodeRESI').show();
        $('#TRU_DetailsView1_selProductTypeRESI').show();
    }
    if (($('#TRU_DetailsView1_selTypeOrg').val() == 'SME') || ($('#TRU_DetailsView1_selTypeOrg').val() == 'C&I')) {
        $("#TRU_DetailsView1_RESI_SME").val('SME');
        $('#TRU_DetailsView1_CompanyName').show();
        $('#TRU_DetailsView1_CompanyABN').show();
        $('#TRU_DetailsView1_selSecondAccountHolder').hide();
        $('#TRU_DetailsView1_SecondAccountHolderTitle').hide();
        $('#TRU_DetailsView1_selSecondAccountHolderTitle').hide();
        $('#TRU_DetailsView1_SecondAccountHolderFirstName').hide();
        $('#TRU_DetailsView1_SecondAccountHolderSurname').hide();
        $('#TRU_DetailsView1_SecondAccountHolderDOB').hide();
        $('#TRU_DetailsView1_selConcessionCard').hide();
        $('#TRU_DetailsView1_selConcessionCardType').hide();
        $('#TRU_DetailsView1_ConcessionCardType').hide();
        $('#TRU_DetailsView1_ConcessionCardEntitlement').hide();
        $('#TRU_DetailsView1_ConcessionCardNo').hide();
        $('#TRU_DetailsView1_ConcessionCardExp').hide();
        $('#TRU_DetailsView1_NameOnConcessionCard').hide();
        $('#TRU_DetailsView1_selSourceCodeRESI').hide();
        $('#TRU_DetailsView1_selProductTypeRESI').hide();
        $('#TRU_DetailsView1_selSourceCodeSME').show();
        $('#TRU_DetailsView1_selProductTypeSME').show();
    }
}

function SourceCodeChanged() {

    $("#TRU_DetailsView1_SourceCode").val($('#TRU_DetailsView1_selSourceCode').val());

}

function SourceCodeRESIChanged() {

    $("#TRU_DetailsView1_SourceCode").val($('#TRU_DetailsView1_selSourceCodeRESI').val());

}

function SourceCodeSMEChanged() {

    $("#TRU_DetailsView1_SourceCode").val($('#TRU_DetailsView1_selSourceCodeSME').val());

}

function MoverSwicherChanged() {

    $("#TRU_DetailsView1_MoverSwicher").val($('#TRU_DetailsView1_selMoverSwicher').val());
    if ($('#TRU_DetailsView1_selMoverSwicher').val() == 'Swicher')
        $('#TRU_DetailsView1_MoveInDate').hide();
    if ($('#TRU_DetailsView1_selMoverSwicher').val() == 'Mover')
        $('#TRU_DetailsView1_MoveInDate').show();
}

function RESI_SME_Changed() {

    $("#TRU_DetailsView1_RESI_SME").val($('#TRU_DetailsView1_selRESI_SME').val());
}

function ID_TypeChanged() {

    $("#TRU_DetailsView1_ID_Type").val($('#TRU_DetailsView1_selID_Type').val());
}

function ElectricityConversionChanged() {

    $("#TRU_DetailsView1_ElectricityConversion").val($('#TRU_DetailsView1_selElectricityConversion').val());
    if ($('#TRU_DetailsView1_selElectricityConversion').val() == 'YES') {
        $("#TRU_DetailsView1_Elec").val('YES');
        $("#TRU_DetailsView1_ElecMonthQuarter").show();
        $("#TRU_DetailsView1_selElecMonthQuarter").show();
        $("#TRU_DetailsView1_ElecMonthQuarterSpend").show();
        $("#TRU_DetailsView1_selElecSpend").show();
        $("#TRU_DetailsView1_ElecTotalAnnualSpend").show();
        $("#TRU_DetailsView1_NMI").show();
        $("#TRU_DetailsView1_ElecMonthQuarter").val('Quarter');
        $("#TRU_DetailsView1_ElecMonthQuarterSpend").val('350');
        $("#TRU_DetailsView1_ElecTotalAnnualSpend").val('1400');
        var elecSpendvalue = $('#TRU_DetailsView1_ElecTotalAnnualSpend').val() * 1;
        var gasSpendvalue = $('#TRU_DetailsView1_GasTotalAnnualSpend').val() * 1;
        var total = elecSpendvalue + gasSpendvalue;
        $("#TRU_DetailsView1_TotalAnnualSpend").val(total);
    }
    if ($('#TRU_DetailsView1_selElectricityConversion').val() == 'NO') {
        $("#TRU_DetailsView1_Elec").val('NO');
        $("#TRU_DetailsView1_ElecMonthQuarter").hide();
        $("#TRU_DetailsView1_selElecMonthQuarter").hide();
        $("#TRU_DetailsView1_ElecMonthQuarterSpend").hide();
        $("#TRU_DetailsView1_selElecSpend").hide();
        $("#TRU_DetailsView1_ElecTotalAnnualSpend").hide();
        $("#TRU_DetailsView1_NMI").hide();
        $("#TRU_DetailsView1_ElecMonthQuarterSpend").val('0');
        $("#TRU_DetailsView1_ElecTotalAnnualSpend").val('0');
        var elecSpendvalue = $('#TRU_DetailsView1_ElecTotalAnnualSpend').val() * 1;
        var gasSpendvalue = $('#TRU_DetailsView1_GasTotalAnnualSpend').val() * 1;
        var total = elecSpendvalue + gasSpendvalue;
        $("#TRU_DetailsView1_TotalAnnualSpend").val(total);
    }
}

function GasConversionChanged() {

    $("#TRU_DetailsView1_GasConversion").val($('#TRU_DetailsView1_selGasConversion').val());
    if ($('#TRU_DetailsView1_selGasConversion').val() == 'YES') {
        $("#TRU_DetailsView1_Gas").val('YES');
        $("#TRU_DetailsView1_GasMonthQuarter").show();
        $("#TRU_DetailsView1_selGasMonthQuarter").show();
        $("#TRU_DetailsView1_GasMonthQuarterSpend").show();
        $("#TRU_DetailsView1_selGasSpend").show();
        $("#TRU_DetailsView1_GasTotalAnnualSpend").show();
        $("#TRU_DetailsView1_MIRN").show();
        $("#TRU_DetailsView1_GasMonthQuarter").val('Quarter');
        $("#TRU_DetailsView1_GasMonthQuarterSpend").val('200');
        $("#TRU_DetailsView1_GasTotalAnnualSpend").val('800');
        var elecSpendvalue = $('#TRU_DetailsView1_ElecTotalAnnualSpend').val() * 1;
        var gasSpendvalue = $('#TRU_DetailsView1_GasTotalAnnualSpend').val() * 1;
        var total = elecSpendvalue + gasSpendvalue;
        $("#TRU_DetailsView1_TotalAnnualSpend").val(total);

    }
    if ($('#TRU_DetailsView1_selGasConversion').val() == 'NO') {
        $("#TRU_DetailsView1_Gas").val('NO');
        $("#TRU_DetailsView1_GasMonthQuarter").hide();
        $("#TRU_DetailsView1_selGasMonthQuarter").hide();
        $("#TRU_DetailsView1_GasMonthQuarterSpend").hide();
        $("#TRU_DetailsView1_selGasSpend").hide();
        $("#TRU_DetailsView1_GasTotalAnnualSpend").hide();
        $("#TRU_DetailsView1_MIRN").hide();
        $("#TRU_DetailsView1_GasMonthQuarterSpend").val('0');
        $("#TRU_DetailsView1_GasTotalAnnualSpend").val('0');
        var elecSpendvalue = $('#TRU_DetailsView1_ElecTotalAnnualSpend').val() * 1;
        var gasSpendvalue = $('#TRU_DetailsView1_GasTotalAnnualSpend').val() * 1;
        var total = elecSpendvalue + gasSpendvalue;
        $("#TRU_DetailsView1_TotalAnnualSpend").val(total);
    }
}

function ConcessionCardTypeChanged() {

    $("#TRU_DetailsView1_ConcessionCardType").val($('#TRU_DetailsView1_selConcessionCardType').val());
}

function FirstAccountHolderTitleChanged() {

    $("#TRU_DetailsView1_FirstAccountHolderTitle").val($('#TRU_DetailsView1_selFirstAccountHolderTitle').val());
}

function SecondAccountHolderTitleChanged() {

    $("#TRU_DetailsView1_SecondAccountHolderTitle").val($('#TRU_DetailsView1_selSecondAccountHolderTitle').val());
}

function TenantOwnerChanged() {

    $("#TRU_DetailsView1_TenantOwner").val($('#TRU_DetailsView1_selTenantOwner').val());
}

function SupplyAddressStateChanged() {

    $("#TRU_DetailsView1_SupplyAddressState").val($('#TRU_DetailsView1_selSupplyAddressState').val());
}

function ElecChanged() {

    $("#TRU_DetailsView1_Elec").val($('#TRU_DetailsView1_selElec').val());
}

function GasChanged() {

    $("#TRU_DetailsView1_Gas").val($('#TRU_DetailsView1_selGas').val());
}

function ProductTypeChanged() {

    $("#TRU_DetailsView1_ProductType").val($('#TRU_DetailsView1_selProductType').val());
}

function ProductTypeRESIChanged() {

    $("#TRU_DetailsView1_ProductType").val($('#TRU_DetailsView1_selProductTypeRESI').val());
}

function ProductTypeSMEChanged() {

    $("#TRU_DetailsView1_ProductType").val($('#TRU_DetailsView1_selProductTypeSME').val());
}

function NoOfPeopleInHouseChanged() {

    $("#TRU_DetailsView1_NoOfPeopleInHouse").val($('#TRU_DetailsView1_selNoOfPeopleInHouse').val());
}

function ElecStatusChanged() {

    $("#TRU_DetailsView1_ElecStatus").val($('#TRU_DetailsView1_selElecStatus').val());
}

function GasStatusChanged() {

    $("#TRU_DetailsView1_GasStatus").val($('#TRU_DetailsView1_selGasStatus').val());
}

function ReasonChanged() {

    $("#TRU_DetailsView1_Reason").val($('#TRU_DetailsView1_selReason').val());
}

function SafetyCertificateRequiredChanged() {

    $("#TRU_DetailsView1_SafetyCertificateRequired").val($('#TRU_DetailsView1_selSafetyCertificateRequired').val());
}

function AdvisedMainSwitchNeedsTurningOffChanged() {

    $("#TRU_DetailsView1_AdvisedMainSwitchNeedsTurningOff").val($('#TRU_DetailsView1_selAdvisedMainSwitchNeedsTurningOff').val());
}

function ExistingTRUEnergyCustomerChanged() {

    $("#TRU_DetailsView1_ExistingTRUEnergyCustomer").val($('#TRU_DetailsView1_selExistingTRUEnergyCustomer').val());
}

function AdditionalQuestionChanged() {

    $("#TRU_DetailsView1_AdditionalQuestion").val($('#TRU_DetailsView1_selAdditionalQuestion').val());
}

function checkbottonclick() {
    var string = "";

    if ($('#TRU_DetailsView1_FirstName').val() == '')
        string = string + "FirstName\n"
    if ($('#TRU_DetailsView1_LastName').val() == '')
        string = string + "LastName\n"
    if ($('#TRU_DetailsView1_Phone').val() == '')
        string = string + "Phone\n"
    if ($('#TRU_DetailsView1_Street').val() == '')
        string = string + "Street\n"
    if ($('#TRU_DetailsView1_Suburb').val() == '')
        string = string + "Suburb\n"
    if ($('#TRU_DetailsView1_StateName').val() == '')
        string = string + "StateName\n"
    if ($('#TRU_DetailsView1_Postcode').val() == '')
        string = string + "Postcode\n"

    if ($('#TRU_DetailsView1_PromotionCode').val() == '')
        string = string + "PromotionCode\n"
    if ($('#TRU_DetailsView1_LeadSource').val() == '')
        string = string + "LeadSource\n"
    if ($('#TRU_DetailsView1_CurrentProvider').val() == '')
        string = string + "CurrentProvider\n"
    if ($('#TRU_DetailsView1_TypeOrg').val() == '')
        string = string + "TypeOrg\n"
    if ($('#TRU_DetailsView1_TotalSites').val() == '')
        string = string + "TotalSites\n"
    if ($('#TRU_DetailsView1_StatusName').val() == '')
        string = string + "StatusName\n"


    if ($('#TRU_DetailsView1_DateConverted').val() == '')
        string = string + "DateConverted\n"
    if ($('#TRU_DetailsView1_OperatorSSE').val() == '')
        string = string + "OperatorSSE\n"
    if ($('#TRU_DetailsView1_VendorID').val() == '')
        string = string + "VendorID\n"
    if ($('#TRU_DetailsView1_SourceCode').val() == '')
        string = string + "SourceCode\n"
    if ($('#TRU_DetailsView1_RESI_SME').val() == '')
        string = string + "RESI_SME\n"
    if ($('#TRU_DetailsView1_MoverSwicher').val() == '')
        string = string + "MoverSwicher\n"
    if ($('#TRU_DetailsView1_ElectricityConversion').val() == '')
        string = string + "ElectricityConversion\n"
    if ($('#TRU_DetailsView1_GasConversion').val() == '')
        string = string + "GasConversion\n"
    if ($('#TRU_DetailsView1_ElecMonthQuarter').val() == '')
        string = string + "ElecMonthQuarter\n"
    if ($('#TRU_DetailsView1_ElecTotalAnnualSpend').val() == '')
        string = string + "ElecTotalAnnualSpend\n"
    if ($('#TRU_DetailsView1_TotalAnnualSpend').val() == '')
        string = string + "TotalAnnualSpend\n"
    if ($('#TRU_DetailsView1_FirstAccountHolderFirstName').val() == '')
        string = string + "FirstAccountHolderFirstName\n"
    if ($('#TRU_DetailsView1_FirstAccountHolderSurname').val() == '')
        string = string + "FirstAccountHolderSurname\n"
    if ($('#TRU_DetailsView1_FirstAccountHolderDOB').val() == '')
        string = string + "FirstAccountHolderDOB\n"
    if ($('#TRU_DetailsView1_ID_Type').val() == '')
        string = string + "ID_Type\n"
    if ($('#TRU_DetailsView1_ID_Number').val() == '')
        string = string + "ID_Number\n"
    if ($('#TRU_DetailsView1_ID_Expiry').val() == '')
        string = string + "ID_Expiry\n"
    if ($('#TRU_DetailsView1_ContactTel').val() == '')
        string = string + "ContactTel\n"
    if ($('#TRU_DetailsView1_Email').val() == '')
        string = string + "Email\n"
    if ($('#TRU_DetailsView1_SupplyAddress').val() == '')
        string = string + "SupplyAddress\n"
    if ($('#TRU_DetailsView1_SupplyAddressSuburb').val() == '')
        string = string + "SupplyAddressSuburb\n"
    if ($('#TRU_DetailsView1_ID_SupplyAddressState').val() == '')
        string = string + "SupplyAddressState\n"
    if ($('#TRU_DetailsView1_SupplyAddressPostcode').val() == '')
        string = string + "SupplyAddressPostcode\n"
    if ($('#TRU_DetailsView1_TenantOwner').val() == '')
        string = string + "TenantOwner\n"
    if ($('#TRU_DetailsView1_Elec').val() == '')
        string = string + "Elec\n"
    if ($('#TRU_DetailsView1_Gas').val() == '')
        string = string + "Gas\n"
    if ($('#TRU_DetailsView1_ProductType').val() == '')
        string = string + "ProductType\n"
    if ($('#TRU_DetailsView1_NMI').val() == '')
        string = string + "NMI\n"
    if ($('#TRU_DetailsView1_MIRN').val() == '')
        string = string + "MIRN\n"

    if (string == "")
        alert("All required fields has been filled!");
    else
        alert("The following fields:\n" + string + "Should be filled!");
}